<template>
  <div class="tab-bar-item" @click="itemclick">
    <div v-if="!istrue"><slot name="item_off"></slot></div>
    <div v-else><slot name="item_on"></slot></div>
    <div :class="{active: istrue}"><slot name="item_name"></slot></div>
  </div>
</template>

<script>
  export default {
    name: "item",
    props:{
      path: String
    },
    methods:{
      itemclick(){
        if(this.path !== this.$route.path){
        this.$router.push(this.path)
        }
      }
    },
    computed:{
      istrue(){
        return this.$route.path.indexOf(this.path) !== -1
      }
    }
  }
</script>

<style scoped>
  .tab-bar-item{
    flex: 1;
    text-align: center;
    height: 49px;
    font-size: 14px;
  }

  .tab-bar-item img{
    margin-top: 3px;
    width: 24px;
    height: 24px;
  }

  .active {
    color: #ff5777;
  }

</style>
